﻿using Domain.Production_Modules;
using Infratructure.Interface;
using MediatR;
using MES.Server.API.Application.Command.Production_Modules.Pulldown;
using ReturnValue;

namespace MES.Server.API.Application.Handler.Production_Modules.Pulldown
{
    
    public class OrderQueryCommandHandler : IRequestHandler<OrderQueryCommand, ApiResult<List<OrderModel>>>
    {
        private readonly IRepository<OrderModel> ClientRepo;
        public OrderQueryCommandHandler(IRepository<OrderModel> ClientRepo)
        {
            this.ClientRepo = ClientRepo;
        }
        public Task<ApiResult<List<OrderModel>>> Handle(OrderQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<OrderModel>> result = new ApiResult<List<OrderModel>>();
            result.Code = StatusCode.Success;
            result.Message = StatusCode.Success.ToString();
            var list = ClientRepo.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
